#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[105];
int b[105];
int n,z=0;
int g()
{
    int ltr=-1,ltb=-1,zf=0;
    for(int i=1;i<=n;i++)
    {
        if(b[i]==-1)
        {
            if(ltr==a[i])
            {
                zf+=a[i];
            }
            ltr=a[i];
        }
        else
        {
            if(ltb==a[i])
            {
                zf+=a[i];
            }
            ltb=a[i];
        }
    }
    return zf;
}
void f(int x)
{
    if(x>n)
    {
        z=max(z,g());
        return ;
    }
    b[x]=1;
    f(x+1);
    b[x]=-1;
    f(x+1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        z=0;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        f(1);
        cout<<z<<"\n";
    }
    return 0;
}
